package com.hhxy.reflect;

import java.lang.reflect.Field;

//Field类中：get、set方法的使用
public class ReflectDemo3 {
    public static void main(String[] args) {
        Student s = new Student();
//        Class sClass = Student.class;
//        Class sClass = Class.forName("com.hhxy.reflect.Student");
        Class sClass = s.getClass();
        try {
            Field adr = sClass.getDeclaredField("age");
            try {
//                adr.setAccessible(true);
                adr.set(s,"1");
                System.out.println(adr.get(s));
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        }

    }
}
